package org.example.aigc.utils;

import java.util.HashMap;

/**
 * 回复信息
 */
public class Reply extends HashMap<String, Object> {

    public Reply(String event) {
        if (event != null) {
            System.out.print(event + "：");
        }
    }

    /**
     * 正常状态
     *
     * @param code 状态代码
     * @param msg  状态信息
     * @return 返回对象
     */
    public Reply ok(int code, String msg) {
        super.put("code", code);
        super.put("msg", msg);
        System.out.println(msg);
        return this;
    }

    /**
     * 异常状态
     *
     * @param code 状态代码
     * @param msg  状态信息
     * @return 返回对象
     */
    public Reply error(int code, String msg) {
        super.put("code", code);
        super.put("msg", msg);
        System.out.println(msg);
        return this;
    }

    public Reply put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    public Object getValue(String key) {
        return super.get(key);
    }
}
